applescript to open safari in private browsing

Hello,

I've read an old locked discussion from year 2010 but the script provided there does not work. Could anyone help me please ? I'm not familiar with scripting. Thanks.

OS X El Capitan (10.11.1)

Posted on Oct 29, 2015 7:32 PM

Reply
10 replies

Oct 29, 2015 7:34 PM in response to harrythehead

the non-working script is :


tell application "Safari" to activate

tell application "System Events" to tell process "Safari"

if menu item "Private Browsing…" of menu 1 of menu bar item 2 of menu bar 1 exists then

click menu item "Private Browsing…" of menu 1 of menu bar item 2 of menu bar 1

keystroke return

else

click menu item "Private Browsing" of menu 1 of menu bar item 2 of menu bar 1

end if

end tell

Aug 1, 2016 11:08 AM in response to jacver57

When I run this script as written on OS X 10.11.6 with Safari 9.1.2, the new private window opens at a normal Safari window size — not full screen.


If I quit Safari that has been opened full screen, and run this script again, paragraph 1 is still the result.


Here is a script that creates a new private window of user configurable proportions:


use scripting additions


set position to {0, 0, 800, 800} as bounding rectangle


tell application "Safari"

activate

tell application "System Events"

tell process "Safari"

keystroke "N" using {shift down, command down}

end tell

end tell

set bounds of front window to position

end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

applescript to open safari in private browsing

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.